import { Entity, PrimaryGeneratedColumn, Column, Index } from 'typeorm';

@Entity('detection_history')
export class DetectionHistory {
  @PrimaryGeneratedColumn('increment')
  id: number;

  @Index()
  @Column({ type: 'varchar', length: 64 })
  userId: string; // 用户ID

  @Column({ type: 'text', comment: '原始图片URL' })
  originalImageUrl: string;

  @Column({ type: 'text', nullable: true, comment: '检测结果图(Base64)' })
  resultImage: string;

  @Column({ type: 'decimal', precision: 3, scale: 2, nullable: true, comment: '堵塞比例' })
  ratio: number;

  @Column({ type: 'varchar', length: 50, nullable: true, comment: '诊断结果' })
  diagnosis: string;

  @Column({ type: 'varchar', length: 255, nullable: true, comment: '原始文件名' })
  filename: string;

  @Column({ type: 'int', nullable: true, comment: '文件大小(字节)' })
  fileSize: number;

  @Column({ type: 'text', nullable: true, comment: '兼容性字段-原图URL' })
  imageUrl: string;

  @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' })
  detectedAt: Date;

  @Column({ type: 'varchar', length: 32, default: 'success' })
  status: string;
}